#include "view_bridge.h"

#include <QApplication>
#include <QFontDatabase>
#include <QDir>
#include <QQmlApplicationEngine>
#include <QDebug>
#include <QQmlContext>

int main(int _argc, char *_argv[])
{
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication::setOrganizationName("epie.com");
    QApplication app(_argc, _argv);

    ViewBridge vb;
    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/qml/Main.qml"));
    engine.rootContext()->setContextProperty("ViewBridge", &vb);
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);

    vb.setQmlWindow(qobject_cast<QWindow*>(engine.rootObjects().at(0)));


    return app.exec();
}
